package crmdna.common;

import com.google.appengine.api.NamespaceManager;
import com.googlecode.objectify.Objectify;
import com.googlecode.objectify.ObjectifyFactory;
import com.googlecode.objectify.ObjectifyService;

import crmdna.client.CustomFieldsEntity;
import crmdna.client.counter.ShardEntity;
import crmdna.client.group.GroupEntity;
import crmdna.client.member.InteractionEntity;
import crmdna.client.member.MemberEntity;
import crmdna.client.member.UnverifiedProgramsEntity;
import crmdna.client.participant.ParticipantEntity;
import crmdna.client.practice.PracticeEntity;
import crmdna.client.program.CheckInEntity;
import crmdna.client.program.ProgramEntity;
import crmdna.client.programtype.ProgramTypeEntity;
import crmdna.client.sequence.SequenceEntity;
import crmdna.client.teacher.TeacherEntity;
import crmdna.client.user.UserEntity;
import crmdna.client.useractivity.UserActivityEntity;
import crmdna.client.venue.VenueEntity;
import crmdna.crmdna.ClientEntity;
import crmdna.crmdna.CrmDnaUserEntity;
import crmdna.custom.isha.IshaConfigEntity;

public class OfyService {
	static {
		factory().register(ClientEntity.class);
		factory().register(CrmDnaUserEntity.class);
		factory().register(GroupEntity.class);
		factory().register(MemberEntity.class);
		factory().register(ProgramEntity.class);
		factory().register(ProgramTypeEntity.class);
		factory().register(VenueEntity.class);
		factory().register(UserEntity.class);
		factory().register(CustomFieldsEntity.class);
		factory().register(SequenceEntity.class);
		factory().register(UserActivityEntity.class);
		factory().register(InteractionEntity.class);
		factory().register(PracticeEntity.class);
		factory().register(TeacherEntity.class);
		factory().register(DummyTestEntity.class);
		factory().register(ParticipantEntity.class);
		factory().register(ShardEntity.class);
		factory().register(CheckInEntity.class);
		factory().register(IshaConfigEntity.class);
		factory().register(UnverifiedProgramsEntity.class);
	}
	
	public static Objectify ofy(String client) {
		NamespaceManager.set(client);
		return ObjectifyService.ofy();					
	}
		
	public static Objectify ofyCrmDna() {
		NamespaceManager.set(Convention.NAMESPACE_CRMDNA);
		return ObjectifyService.ofy();
	}
	
	public static ObjectifyFactory factory() {
		return ObjectifyService.factory();		
	}		
}